var app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
  money:'',
  tixian:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      this.setData({
        opid: options.openOId,
        money: options.yue,
        is_bee: options.is_bee
      })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  tx:function(){
    var that = this;
    
    wx.showLoading({
      title: '提现中...',
    })
    if (that.data.tixian == ''){
      wx.showToast({
        title: '输入提现金额!',
        icon: 'none',
        duration: 2000,
      });
    }else{
      if (that.data.is_bee == 0) {
        wx.showToast({
          title: '提现失败,请你关注蜜蜂圈公众号!',
          icon: 'none',
          duration: 2000,
        });
        return
      }

      wx.request({
        url: app.globalData.phpUrl + 'user/api',
        method: 'POST',
        data: { api_name: 'withdraw', openid: that.data.opid, money: Number(that.data.tixian) },
        success: function (d) {
          wx.hideLoading();

          console.log(d.data.code)
          if (d.data.code == 1) {
            wx.showToast({
              title: '提现成功!',
              duration: 2000
            })
          } else {
            wx.showToast({
              title: d.data.msg,
              image: '../../../../images/attend.png',
              duration: 4000
            })
          }
        }
      })
    }
  },

  inputMoney:function(e){
    this.setData({
      tixian: e.detail.value
    })
  },

  onShow: function () {
  
  },
  tixian:function(){
    var that = this;
    that.setData({
      tixian: that.data.money
    })
  }
})